import React,{useMemo } from 'react'
import { useSelector } from 'react-redux'
import Login from './views/Login'
import Manage from './views/Manage'

import 'antd/dist/antd.css';
import { Navigate, Route, Routes } from 'react-router-dom';

function App() {
    const userInfo = useSelector(state => state.userInfo);
    const isLogin = useMemo(() => !!userInfo._id, [userInfo])
    console.log(isLogin,'isLogin','userInfo.id',userInfo)
    return (
       <Routes>
            <Route path='/login' element={<Login/>}/>
            {
               isLogin ?
               <Route path='/manage/*' element={<Manage user={userInfo}/>}/>
               :
               null
            }
            <Route path='*' element={<Navigate to={isLogin ? '/manage':'/login'}/>}/>
       </Routes>
    )
}

export default App